This application relates generally to systems for computer graphics. More specifically, the present invention includes a method and apparatus for efficiently managing texture memory.
Computer systems (and related devices) typically create three-dimensional images using a sequence of stages known as a graphics pipeline. During early pipeline stages, images are modeled using a mosaic-like approach where each image is composed of a collection of individual points, lines and polygons. These points, lines and polygons are know as primitives and a single image may require thousands, or even millions, of primitives. Each primitive is defined in terms of its shape and location as well as other attributes, such as color and texture.
The primitives used in early pipeline stages are transformed, during a rasterization stage, into collections of pixels. The rasterization stage is often performed by a specialized graphics processor (in low-end systems, rasterization may be performed directly by the host processor) and the resulting pixels are stored in a device known as a frame buffer. A frame buffer is a memory device that includes individual memory locations for each pixel.
During the rasterization stage, the graphics processor renders each primitive into the frame buffer. The graphics processor accomplishes this task by determining which frame buffer memory locations are included within the bounds of each primitive. The included memory locations are then initialized to reflect the attributes of the primitive, including color and texture.
Textures are the visual or tactile surface characteristics and appearance of an object. Depicting texture in a realistic manner is an important part of making three-dimensional images believable and is usually done by mapping texture images onto the primitives within an image. This process is known as texture mapping.
Texture mapping may be done by tiling one or more texture images over an area. To improve realism, a series of texture image tiles may be created to represent the texture at different distances away from the user""s viewing point. The graphics system dynamically selects the correct texture from the series based on the distance to the eye point and viewing angle. The entire series is typically stored in a data structure known as a MIPmap. MiPmaps are pre-filtered, lower-resolution versions of a texture image.
Global texturing involves using a texture image that represents a large area. This texture image is created from image data such as satellite or aerial photographs. This global texture image is then mapped onto a surface image in order to provide the texture. Global texturing creates a type of photo realism that cannot be attained with traditional texturing methods.
Global textures may be quite large. As a result, these textures are usually subdivided and only the parts of the global texture image that are actually used in rendering an image are stored in texture memory. The rest is stored in main memory or on disk. As the point of view moves, the portion of the global texture image that is stored in texture memory is updated to reflect the new point of view.
One problem with some approaches to global texturing is texture memory fragmentation. Fragmentation occurs as portions of the global texture are paged into and out of the texture memory. Before the graphics system pages in a portion, it has to determine the portion""s size. Then the graphics system must determine whether there is a large enough space available in the texture memory. If there is space available, the system may page in that portion. If not, then it will have to page another portion out of the texture memory before paging in the new portion from disk. As more portions are paged in and out, gaps start to form in texture memory. This makes it more difficult for the graphics system to find suitably sized spaces in the texture memory to page in more portions of the global texture.
Another problem occurs when the graphics system accesses portions of the global texture from disk in rapid succession. First, the graphics system has to determine the size of the portion. Then it has to find a large enough space in the texture memory before it can page in that portion from disk. This slows down the rate at which the graphics system can page the data into and out of the texture memory.
Thus, a need exists for an efficient method for managing texture memory that deals effectively with large homogenous texture image datasets. This need is especially important for simulation environments, such as flight simulators and for highly realistic virtual reality systems.
An embodiment of the present invention includes a method and apparatus for efficiently managing texture memory in computer graphics systems. For the method of the present invention, all of the texture images are stored in discrete memory-aligned tiles. Storing the texture images into memory-aligned tiles helps to avoid fragmentation in the texture memory.
With this method, larger texture images are divided up into smaller tiles so that they will fit in any available tile region in texture memory. Small texture images usually fit into a single tile and therefore do not usually have to be divided up. Texture images that are larger than a tile region are split up into tile-sized images that are stored individually in any available tile region of texture memory. By dividing up the larger texture images this way, the texture memory is used more efficiently because any gaps that appear in the texture memory due to fragmentation may be filled by the tile-sized images.
This method requires that the graphics system keep track of the location of each of the tiles in texture memory. This makes paging the data into and out of the texture memory more efficient. The locations of the each of the tiles is stored in an address table in memory.
In one embodiment of the invention, the address table may also contain an address value that indicates that a texture image has no information for a particular MIP level. For example, a tile with no texture data could have an xe2x80x9cemptyxe2x80x9d address in the relevant address table entry. This indicator could then direct the texture fetch to another MIP level by simple bit manipulation.
This indicator may also be used for freeing an existing tile in texture memory. This is done by marking the texture table address pointing to the tile location as xe2x80x9cemptyxe2x80x9d and then directing the texture fetch to the next level of available MIP. The texture memory tile is then made available for other textures to use.
To introduce a new data tile into texture memory, the system can page data to a free tile in texture memory. This data may be paged into the texture memory even while the texture image is being used. Once the data is in texture memory, the address table is updated and the graphics system may access the newly paged data immediately.
Advantages of the invention will be set forth, in part, in the description that follows and, in part, will be understood by those skilled in the art from the description herein. The advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the appended claims and equivalents.